package com.lwy.controller;

import com.github.pagehelper.PageInfo;
import com.lwy.dao.BookNovelChapterMapper;
import com.lwy.entity.BookNovelChapter;
import com.lwy.service.impl.BookNovelChapterServiceImpl;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

//章节controller控制层
@RestController
@RequestMapping("chapter")
public class BookNovelChapterController {

    @Resource
    private BookNovelChapterServiceImpl bookNovelChapterService;
    @Resource
    private BookNovelChapterMapper bookNovelChapterMapper;

//    章节分页
    @RequestMapping("page")
    public PageInfo<BookNovelChapter> find(String m,Integer novel_id, Integer pageNum, Integer pageSize){
        return bookNovelChapterService.page(m,novel_id,pageNum,pageSize);
    }

//    小说简介
    @RequestMapping("contents")
    public List<BookNovelChapter> listAll(Integer novel_id){
        return bookNovelChapterService.listAll(novel_id);
    }

//    小说总量
    @RequestMapping("count")
    public Integer count(Integer novel_id){
        return bookNovelChapterMapper.count(novel_id);
    }

//    新建的小说
    @RequestMapping("newList")
    public BookNovelChapter newLisst(Integer novel_id){
       return bookNovelChapterService.newList(novel_id);
    }
//    新增
    @RequestMapping("save")
    public Integer save(String title,String chapter,Integer novel_id){
        return bookNovelChapterService.saveChapter(title,chapter,novel_id);
    }
    @RequestMapping("firstList")
    public BookNovelChapter first(Integer novel_id){
        return bookNovelChapterMapper.firstByList(novel_id);
    }
}
